(function($) {
	$.fn.extend({
		scrollToTop : function(options) {
			var defaults = {
				speed : "fast",
				start : 0,
				active : 0
			};
			var options = $.extend(defaults, options);
			return this.each(function() {
				var o = options;
				var scrollDiv = $(this);
				$(this).hide().removeAttr("href").css("cursor", "pointer");
				if ($(window).scrollTop() > o.start) {
					$(this).fadeIn(o.speed);
				}
				$(window).scroll(function() {
					if ($(window).scrollTop() > o.start) {
						if(!o.active)
						{
						$(scrollDiv).fadeIn(o.speed);
						}
					} else {
						$(scrollDiv).fadeOut(o.speed);
					}
				});
				scrollDiv.click(function(event) {
					o.active = 1;
					$.scrollTo('#wrapper',o.speed,function(){
						o.active = 0;
					});

				});
			});
		}
	});
})(jQuery);